#include "PheramoneTrail.h"

PheramoneTrail::PheramoneTrail(Unit* unit,int maxLength,double strength)
{
  this->unit = unit;
  this->maxLength = maxLength;
  this->strength = strength;
}

void PheramoneTrail::setMaxLength(int maxLength)
{
  this->maxLength = maxLength;
}

std::list<Potential*> PheramoneTrail::getTrail()
{
  std::list<Potential*> potentials;
  int timer = maxLength;
  if (trail.size() > 0) {
    for each(Position pos in trail) {
      potentials.push_back(new Potential(strength,width*timer/maxLength,&pos));

      Broodwar->drawCircle(CoordinateType::Map,pos.x(),pos.y(),width*timer/maxLength,Colors::Purple,false);
    }
  }
  return potentials;
}

void PheramoneTrail::update()
{
  trail.push_front(unit->getPosition());
  if (trail.size() > maxLength) trail.pop_back(); // Remove trail after a while
}
